package com.ssyc.common.quanzi;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.common.R;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.common.utils.ScreenUtils;
import com.ssyc.common.utils.UiUtils;

import java.util.List;

/**
 * 个人资料--相册
 * Created by Administrator on 2018/7/10 0010.
 */

public class PicRvAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context context;
    private RelativeLayout.LayoutParams lp;

    public PicRvAdapter(Context context, int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);
        this.context = context;
        //获取屏幕宽度
        int screenWidth = ScreenUtils.getScreenWidth(context);
        lp = new RelativeLayout.LayoutParams((screenWidth - UiUtils.dp2px(62 + 18 + 24 + 16)) / 4, ViewGroup.LayoutParams.MATCH_PARENT);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        //外层布局
        RelativeLayout rlOut = helper.getView(R.id.rl_out);
        rlOut.setLayoutParams(lp);
        //头像
        RoundedImageView ivHead = helper.getView(R.id.iv_head);
        ImageUtil.displayImage(context, ivHead, item, R.drawable.base_default_head);
    }
}
